package your.rfgui.application.controller.otherExamples;

import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import org.apache.log4j.Logger;
import your.rfgui.application.data.MyDataItem;
import your.rfgui.extgui.controller.tree.SimpleTreeController;
import your.rfgui.extgui.controller.tree.TreeViewNode;

@ManagedBean(name = "simpletree")
@SessionScoped
public class MySimpleTreeController extends SimpleTreeController {

   private static final Logger log = Logger.getLogger(MySimpleTreeController.class);

   public MySimpleTreeController() {
      populate1();
   }

   private void populate1() {
      List<TreeViewNode> rootNodes = new ArrayList<TreeViewNode>();
      for (int i = 0; i < 4; i++) {
         TreeViewNode directory = new TreeViewNode("Directory " + i);
         rootNodes.add(directory);
         for (int j = 0; j < 6; j++) {
            new TreeViewNode(directory, "Directory " + i + " Label " + j);
         }
      }
      setRootNodes(rootNodes);
   }

   private void populate2() {
      List<TreeViewNode> rootTreeNodes = new ArrayList<TreeViewNode>();
      for (int i = 0; i < 4; i++) {
         TreeViewNode directory = new TreeViewNode(new MyDataItem("Directory " + i));
         rootTreeNodes.add(directory);
         for (int j = 0; j < 6; j++) {
            TreeViewNode child = new TreeViewNode(directory, new MyDataItem("Directory " + i + " Label " + j));
         }
      }
      setRootNodes(rootTreeNodes);
   }
}
